This invention relates generally to a method and system for managing folders and, in particular, to a method and system in which an application program can access the folder management capabilities of a shell program.
Computer systems have operating systems that have functions through which an application program can interact with files maintained by the operating system. These functions include opening, moving, copying, deleting, or renaming a file. These functions can also include creating and naming directories (also known as xe2x80x9cfoldersxe2x80x9d) or subdirectories in which to store files.
Typical computer systems include a shell, which is a program that provides direct communications between a user and the operating system. For example, a shell may provide the capability to list, delete, and copy files, to start the execution of other programs, to configure resources, etc. The shell may be implemented as a single computer program or as several computer programs. For example, a shell may include a file manager program that allows a user to manage the files stored by a file system portion of the operating system. Such a file manager program can move a file from one folder to another, copy a file, delete a file, rename a file, change various properties associated with the file, and launch an application program associated with a file. A file manager program can also create new folders. File manager programs typically provide comprehensive functionality for managing files and folders.
Application programs often provide capabilities to manage files, but such capabilities are often limited. For example, typical word processing programs can only open files and save files which are the capabilities needed to support word processing. Thus, a user wishing to manipulate a file using a function other than opening or saving needs to switch from the word processing program to the file manager program to manipulate the file. For example, when a user enters new data using a word processing program; the user often wishes to save that new data in a new file stored in a new folder. In order to do this, the user enters the new data using the word processing program, switches from the word processing program to the file manager program to create the new folder, and then switches back to the word processing program to save the new data in a new file in the newly created folder.
Some application programs include additional file manipulation functions that include moving, renaming, and deleting files. However, each developer of an application program that wants to include additional file manipulation functions needs to develop the user interface and computer code to support such functions. This development increases the burden on the application developer and creates a lack of consistency of the user interface for managing files between the operating system and the application programs. Additionally, even if an application developer modeled the user interface after that provided by the file manager program, if the user interface of the file manager program was later changed, there would then be a lack of consistency.
The present invention is described below using some object-oriented techniques; thus, an overview of well-known object-oriented programming techniques is provided. Two common characteristics of object-oriented programming languages are support for data encapsulation and data type inheritance. Data encapsulation refers to the binding of functions and data. Inheritance refers to the ability to declare a data type in terms of other data types. In the C++ language, data encapsulation and inheritance are supported through the use of classes. A class is a user-defined type. A class declaration describes the data members and function members of the class. A function member is also referred to as a method of a class. The data members and function members of a class are bound together in that the function operates on an instance of the class. An instance of a class is also called an object of the class. Thus, a class provides a definition for a group of objects with similar properties and common behavior.
To allocate storage for an object of a particular type (class), an object is instantiated. Once instantiated, data can be assigned to the data members of the particular object. Also, once instantiated, the function members of the particular object can be invoked to access and manipulate the data members. Thus, in this manner, the function members implement the behavior of the object, and the object provides a structure for encapsulating data and behavior into a single entity.
To support the concept of inheritance, classes may be derived from (based upon the declaration of) other classes. A derived class is a class that inherits the characteristicsxe2x80x94data members and function membersxe2x80x94of its base classes. A class that inherits the characteristics of another class is a derived class. A class that does not inherit the characteristics of another class is a primary (root) class. A class whose characteristics are inherited by another class is a base class. A derived class may inherit the characteristics of several classes; that is, a derived class may have several base classes. This is referred to as multiple inheritance.
A class may also specify whether its function members are virtual. Declaring that a function member is virtual means that the function can be overridden in a polymorphic manner by a function of the same name and type in a derived class. If a virtual function is declared without providing an implementation, then it is referred to as a pure virtual function. A pure virtual function is a virtual function declared with the pure specifier, xe2x80x9c=0xe2x80x9d. If a class specifies a pure virtual function, then any derived class needs to specify an implementation for that function member before that function member may be invoked. A class which contains at least one pure virtual function member is an abstract class.
FIG. 1 is a block diagram illustrating typical data structures used to represent an object. An object is composed of instance data (data members) and function members, which implement the behavior of the object. The data structures used to represent an object comprise instance data structure 101, virtual function table 102, and the function members 103, 104, 105. The instance data structure 101 contains a pointer to the virtual function table 102 and contains data members. The virtual function table 102 contains an entry for each virtual function member defined for the object. Each entry contains a reference to the code that implements the corresponding function member. The layout of this sample object conforms to models described in U.S. Pat. No. 5,297,284, entitled xe2x80x9cA Method for Implementing Virtual Functions and Virtual Bases in a Compiler for an Object Oriented Programming Language,xe2x80x9d which is hereby incorporated by reference. In the following, an object will be described as an instance of a class as defined by the C++ programming language. One skilled in the art would appreciate that other object models can be defined using other programming languages.
An advantage of using object-oriented techniques is that these techniques can be used to facilitate the sharing of objects. For example, a program implementing the function members of an instantiated object (a xe2x80x9cserver programxe2x80x9d) can share the object with another program (a xe2x80x9cclient programxe2x80x9d). To allow an object of an arbitrary class to be shared with a client program, interfaces are defined through which an object can be accessed without the need for the client program to have access to the class definitions at compile time. An interface is a named set of logically related function members. In C++, an interface is an abstract class with no data members and whose virtual functions are all pure. Thus, an interface provides a published protocol for two programs to communicate. Interfaces are typically used for derivation; a program defines (implements) classes that provide implementations for the interfaces the classes are derived from. Thereafter, objects are created as instances of these derived classes. Objects instantiated from a derived class implementing particular interfaces are said to xe2x80x9csupportxe2x80x9d the interfaces. An object supports one or more interfaces depending upon the desired functionality.
When a client program desires to share an object, the client program needs access to the code that implements the interfaces for the object (the derived class code). To access the derived class code (also referred to as class code), each class implementation is given a unique class identifier (a xe2x80x9cCLSIDxe2x80x9d). For example, code implementing a spreadsheet object developed by Microsoft Corporation may have a class identifier of xe2x80x9cMSSpreadsheet,xe2x80x9d while code implementing a spreadsheet object developed by another corporation may have a class identifier of xe2x80x9cLTSSpreadsheet.xe2x80x9d A persistent registry in each computer system is maintained that maps each CLSID to the code that implements the class. Typically, when a spreadsheet program is installed on a computer system, the persistent registry is updated to reflect the availability of that class of spreadsheet objects. So long as a spreadsheet developer implements each function member defined by the interfaces to be supported by spreadsheet objects and so long as the persistent registry is maintained, the client program can access the function members of shared spreadsheet objects without regard to which server program has implemented them or how they have been implemented.
Since an object may support some interfaces and not others, a client program would need to determine at runtime whether a particular object supports a particular interface. To enable this determination, every object supports the interface IUnknown, which contains a function member, QueryInterface, that indicates which interfaces are implemented for the object. The method QueryInterface is defined as follows:
virtual HRESULT QueryInterface (REFIID iid, void**ppv)=0;
The method QueryInterface is passed an interface identifier in parameter iid (of type REFIID) and returns in parameter ppv a pointer to the implementation of the identified interface of the object for which the method is invoked. If the object does not support the interface, then the method returns a false. The type HRESULT indicates a predefined status.
FIG. 2 is a symbolic representation of an object. In the following description, an object data structure is represented by the shape 201 labeled with the interfaces through which the object may be accessed. As shown, object 201 supports IInterface1 and IInterface2.
The present invention provides a system and method that allows application programs to use the file management capabilities implemented by shell through a file manager program. In a preferred embodiment, application programs are provided with an application programming interface (GetFileName API) to retrieve file names using a common dialog box implementation. The shell uses an interface (IShellView) to control a ShellView window in which the contents of a current folder are displayed and manipulated. The common dialog box implementation uses the IShellView interface so that it can provide the same behavior as the shell provides for managing files and folders. The ShellView window has an associated ShellView window procedure and an ShellView class. The ShellView window procedure processes messages for the ShellView window. The ShellView class provides an implementation of the IShellView interface. Since the GetFileName API uses the implementation of the IShellView interface provided by the file manager program, the application programs that use the GetFileName API provide the same user interface and the same functionality that is provided by the file manager program.
A preferred embodiment provides a method in a computer system for allowing comprehensive object manipulation to a user during a get object name function. The computer system has an object manager that provides comprehensive object manipulation to the user. Upon invocation of the get object name function, the method creates a dialog window for receiving the name of an object. The method then creates a view window provided by the object manager and provides a folder of objects to the view window for display and manipulation. Under control of the view window, the method then receives user requests to manipulate the displayed objects. The method then manipulates the displayed object, and notifies the dialog window of changes in state of the displayed objects. Under control of the dialog window, the method updates the dialog window to reflect the change in the state wherein the view window provides a comprehensive object manipulation to a user within context of a get object name function.